/**
 * 
 */
package com.cn.practice.bridge;

/**
 * 桥接模式练习
 * 桥接模式的核心 抽象层聚合实现层接口
 * @author zhangyang
 *
 */
public class BridgePractice {
public static void main(String[] args) {
	XiaomiPhone xiaomiPhone = new XiaomiPhone(new LEDPhone());
	xiaomiPhone.call();
}
}

/**
 * 手机品牌+手机屏幕
 * 使用小米OLED屏手机打电话
 * 方案思考 任何品牌的手机都能打电话，发短信 那么把手机功能设置为接口
 * OLED屏幕作为实现类实现接口
 * @author zhangyang
 *
 */
interface TelePhone{
	void call();
	void sendMessage();
}

class LEDPhone implements TelePhone{

	@Override
	public void call() {
		// TODO Auto-generated method stub
		System.out.println("使用led手机打电话");
	}


	@Override
	public void sendMessage() {
		// TODO Auto-generated method stub
		System.out.println("使用led手机发短信");
	}
	
}
abstract class PhoneBrand{
	String name;
	TelePhone phone;
	public PhoneBrand(TelePhone phone) {
		super();
		this.phone = phone;
	}
	
}
class XiaomiPhone extends PhoneBrand{

	/**
	 * @param phone
	 */
	public XiaomiPhone(TelePhone phone) {
		super(phone);
		// TODO Auto-generated constructor stub
	}
	
	public void call() {
		this.name="小米";
		System.out.println("使用"+this.name);
		this.phone.call();
	}
}
